//
//  zouchuquxqViewController.m
//  PASystem
//
//  Created by michael on 16/8/22.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "zouchuquxqViewController.h"
#import "qiyelist.h"
#import "wllist.h"
#import "houqin.h"
#import "xinwen.h"
#import "anquan.h"
#import "yiliao.h"
@interface zouchuquxqViewController ()

@end

@implementation zouchuquxqViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
         self.title = _string;
    self.view.backgroundColor = [UIColor whiteColor];
    [self initview];
    }
- (void)initview{


_view0 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 40)];
_view0.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_view0];
NSArray *array = @[@"企业组",@"外联组",@"后勤组",@"新闻组",@"安全组",@"医疗组"];


float itemWidth = (KScreenWidth) /array.count;

for (int i = 0; i<array.count; i++) {

_btn = [UIButton buttonWithType:UIButtonTypeCustom];
    _btn.frame  = CGRectMake(itemWidth*i, 0, itemWidth, 40);
[_btn setTitle:array[i] forState:UIControlStateNormal];
_btn.tag = i;
        [_btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [_btn setTitleColor:[UIColor blueColor ] forState:UIControlStateSelected];
_btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
_btn.backgroundColor= [UIColor whiteColor];

//        _btn.layer.cornerRadius = 10;
//        [_btn.layer setBorderColor:[UIColor whiteColor].CGColor];
//        [_btn.layer setBorderWidth:2];
//        _btn.layer.masksToBounds = YES;

[_btn addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
[_view0 addSubview:_btn];
//[_scrollView addSubview:_btn];

}
qiyelist *view4 = [[qiyelist alloc]initWithFrame:CGRectMake(0, _view0.bottom, KScreenWidth, KScreenHeight-64-46-40)];
    view4.tag = 11;
    view4.id = _id;
[self.view addSubview:view4];


//[_scrollView addSubview:view4];

}
- (void)action:(UIButton *)btn{
//     btn.backgroundColor = [UIColor whiteColor];
        [btn.titleLabel setTextColor:[UIColor blueColor]];
   btn.selected = YES;
   if (self.lastBtn == btn) {
 
//        btn.backgroundColor = [UIColor whiteColor];
        [btn.titleLabel setTextColor:[UIColor blueColor]];
        self.btnClick ++;
        
    }else {

//        self.lastBtn.backgroundColor =[UIColor blueColor];
        [self.lastBtn.titleLabel setTextColor:[UIColor blackColor]];
        
        self.btnClick = 0;
    }
    
   self.lastBtn = btn;



for (UIView *view in self.view.subviews) {
    if (view.tag ==11) {
    [view removeFromSuperview];
    
}
//NSLog(@"%lu",(unsigned long)self.view.subviews.count);
}

if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"0"]) {
    qiyelist *view = [[qiyelist alloc]initWithFrame:CGRectMake(0, _view0.bottom, KScreenWidth, KScreenHeight-64-46-40)];
    view.tag = 11;
    view.id = _id;
[self.view addSubview:view];
//[_scrollView addSubview:view];

}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"1"]) {
    wllist *view1 = [[wllist alloc]initWithFrame:CGRectMake(0, _view0.bottom, KScreenWidth, KScreenHeight-64-46-40)];
//    view1.backgroundColor = [UIColor yellowColor];
    view1.tag = 11;
        view1.id = _id;
[self.view addSubview:view1];
//[_scrollView addSubview:view1];
}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"2"]) {
    houqin *view2 = [[houqin alloc]initWithFrame:CGRectMake(0, _view0.bottom, KScreenWidth, KScreenHeight-64-46-40)];
//    view2.backgroundColor = [UIColor greenColor];
      view2.id = _id;
    view2.tag = 11;
    
[self.view addSubview:view2];
//[_scrollView addSubview:view2];
}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"3"]) {
    xinwen *view3 = [[xinwen alloc]initWithFrame:CGRectMake(0, _view0.bottom, KScreenWidth, KScreenHeight-64-46-40)];
    view3.tag = 11;
         view3.id = _id;
[self.view addSubview:view3];
//[_scrollView addSubview:view3];
}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"4"]) {
    anquan *view3 = [[anquan alloc]initWithFrame:CGRectMake(0, _view0.bottom, KScreenWidth, KScreenHeight-64-46-40)];
    view3.tag = 11;
         view3.id = _id;
[self.view addSubview:view3];
//[_scrollView addSubview:view3];
}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"5"]) {
    yiliao *view3 = [[yiliao alloc]initWithFrame:CGRectMake(0, _view0.bottom, KScreenWidth, KScreenHeight-64-46-40)];
    view3.tag = 11;
         view3.id = _id;
[self.view addSubview:view3];
//[_scrollView addSubview:view3];
}

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
